using TaskTodo.Localization;
using Volo.Abp.Authorization.Permissions;
using Volo.Abp.Localization;

namespace TaskTodo.Permissions
{
    public class TaskTodoPermissionDefinitionProvider : PermissionDefinitionProvider
    {
        public override void Define(IPermissionDefinitionContext context)
        {
            var myGroup = context.AddGroup(TaskTodoPermissions.GroupName, L("Permission:TaskTodo"));

            var todoPermission = myGroup.AddPermission(TaskTodoPermissions.Todo.Default, L("Permission:Todo"));
            todoPermission.AddChild(TaskTodoPermissions.Todo.Create, L("Permission:Create"));
            todoPermission.AddChild(TaskTodoPermissions.Todo.Update, L("Permission:Update"));
            todoPermission.AddChild(TaskTodoPermissions.Todo.Delete, L("Permission:Delete"));
        }

        private static LocalizableString L(string name)
        {
            return LocalizableString.Create<TaskTodoResource>(name);
        }
    }
}
